/*
 * SDLBall.cpp
 *
 *  Created on: Nov 18, 2010
 *      Author: timmeh
 */
#define res SDLResource::Instance()

#include "SDLBall.h"
#include "SDLResource.h"
#include "Vector2.h"
#include <iostream>
using namespace std;

namespace bo_sdl {

bo_sdl::SDLBall::SDLBall() {

}

bo_sdl::SDLBall::~SDLBall() {

}

/**
 * Converts the virtual position to the "real position" on the screen, and blits the set sprite
 */
void bo_sdl::SDLBall::Visualize(){
	Vector2 newPos(Ball::GetPos().GetX(), Ball::GetPos().GetY());
	newPos.ConvToScreenCoords(res->GetScale());
	newPos - res->GetScale()*this->GetRadius();
	res->BlitToScreen(this->fBallSprite, newPos);
}

/**
 * Loads the sprite of the ball, and calculates its virtual radius
 */
void bo_sdl::SDLBall::SetSprite(const char* fileName, const double scale){
	SDL_Surface* img = IMG_Load(fileName);
	fBallSprite = img;
	Ball::SetRadius((img->w/2) / scale);
}


}
